home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / gfx / 3d / MyMPEG_gui.lha / MyMPEG_gui / MyMPEG.gui-3.5 < prev    next >
Text File  |  1997-04-23  |  24KB  |  694 lines

  1. (
  2. ( MyMPEG - create MPEG-animations with a GUI
  3. (          © Marc Bartels 12.02.97 first invention
  4. (          $VER: MyMPEG 1.0 (16 Mar 1997)
  5.  
  6. ?& MyMPEG_GUI NOT ?IF
  7. ( define MyMPEG_GUI to make sure that these will not be defined again later.
  8.  
  9. 1 CONSTANT MyMPEG_GUI
  10.  
  11. ( this file contains necessary RPL definitions for GUI words.
  12.  
  13. "r3d3:rpl/sys/ui.rpl" LOAD
  14. "r3d3:rpl/sys/io.rpl" LOAD
  15. "r3d3:rpl/sys/view.rpl" LOAD
  16. "r3d3:rpl/sys/windows.rpl" LOAD
  17. "r3d3:rpl/sys/render.rpl" LOAD
  18. "r3d3:rpl/sys/animation.rpl" LOAD
  19.  
  20. ( Variables, make sure these are unique. Conflicts with other RPL gui
  21. ( programs can crash the system.
  22.  
  23. 256 STRING   sDefPic
  24. 256 STRING   sDefMPEG
  25. 256 STRING   sDefMPEG2
  26. 256 STRING   sDefPlayer
  27. 256 STRING   sBuff
  28. 30  STRING   sBuff1
  29. 30  STRING   sBuff2
  30.     VARIABLE mympegaWindow
  31.     VARIABLE mympegaCheck1
  32.     VARIABLE mympegaCheck2
  33.     VARIABLE iCheck
  34.     VARIABLE mympegaMx1
  35.     VARIABLE mympegaStrX
  36.     VARIABLE mympegaStrY
  37.     VARIABLE mympegiStrX
  38.     VARIABLE mympegiStrY
  39.     VARIABLE mympegaMx2
  40. 30  STRING   mympegsStrI
  41. 30  STRING   mympegsStrP
  42. 30  STRING   mympegsStrB
  43. 30  STRING   mympegsStrV
  44.     VARIABLE mympegaPat
  45. 30  STRING   mympegsPat
  46.     VARIABLE mympegaStrV
  47.     VARIABLE mympegaView
  48.     VARIABLE mympegaMx3
  49. 256 STRING   mympegsPPath
  50. 256 STRING   mympegsPName
  51. 256 STRING   mympegsPFull
  52.     VARIABLE iCount
  53.     VARIABLE mympegaPic
  54.     VARIABLE mympegaPB
  55.     VARIABLE mympegiX
  56.     VARIABLE mympegaFile
  57. 256 STRING   mympegsMFull
  58.     VARIABLE mympegaMPG
  59.     VARIABLE mympegaMB
  60.     VARIABLE mympegaSB
  61.     VARIABLE mympegaCB
  62.     VARIABLE iStartFrm
  63.     VARIABLE iGOP
  64.     VARIABLE iOutput
  65. 30  STRING   sFrmCmd
  66.  
  67. ( ############################################################ )
  68. ( ##########  Change the following to your needs: ############ )
  69.  
  70. 15                                       CONSTANT FONTSIZE
  71. "RAM:t/preview."                                  sDefPic    CPY
  72. "ram:"                                            sDefMPEG   CPY
  73. "rEaL:anim/"                                      sDefMPEG2  CPY
  74. "dh0:viewer/mpeg_play dither cybergfx loop quiet" sDefPlayer CPY
  75.  
  76. ( ############################################################ )
  77.  
  78. ( Callbacks for buttons. When the user clicks buttons, these words are called.
  79. ( and other Word definitions.
  80.  
  81. : mympegcbCheck1  ( simulates a radiobutton, first knop
  82.     IF
  83.         UI_Done 0 UICB_Checked  mympegaCheck2 FETCH UI_SETATTRS
  84.     ELSE
  85.         UI_Done 1 UICB_Checked  mympegaCheck1 FETCH UI_SETATTRS
  86.     ENDIF
  87. ;
  88.  
  89. : mympegcbCheck2  ( simulates a radiobutton, second knop
  90.     IF
  91.         UI_Done 0 UICB_Checked  mympegaCheck1 FETCH UI_SETATTRS
  92.     ELSE
  93.         UI_Done 1 UICB_Checked  mympegaCheck2 FETCH UI_SETATTRS
  94.     ENDIF
  95. ;
  96.  
  97. : SetPicSize  ( writes the framesize into the Rendersettings of the relevant View window
  98.               ( because the RPL-includes for Amiga v3.5 does not yet exist numeral values are used
  99.     mympegiStrY FETCH
  100.     mympegsStrV WND_ADDR  W.aData + FETCH
  101.     1106 ( VR.bHeight at first h then w ) + STORE
  102.     mympegiStrX FETCH
  103.     mympegsStrV WND_ADDR  W.aData + FETCH
  104.     1104 ( VR.bWidth ) + STORE
  105. ;
  106.  
  107. : mympegcbMx1  ( Cyclegadget to choose framesize, here without polling from array, old version
  108.     DUP 0 = IF
  109.         128 mympegiStrX STORE
  110.         96  mympegiStrY STORE
  111.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  112.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  113.     ENDIF
  114.     DUP 1 = IF
  115.         160 mympegiStrX STORE
  116.         112  mympegiStrY STORE
  117.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  118.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  119.     ENDIF
  120.     DUP 2 = IF
  121.         160 mympegiStrX STORE
  122.         128  mympegiStrY STORE
  123.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  124.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  125.     ENDIF
  126.     DUP 3 = IF
  127.         352 mympegiStrX STORE
  128.         240  mympegiStrY STORE
  129.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  130.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  131.     ENDIF
  132.     DUP 4 = IF
  133.         320 mympegiStrX STORE
  134.         256  mympegiStrY STORE
  135.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  136.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  137.     ENDIF
  138.     5 = IF
  139.         UI_Done 0 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  140.         UI_Done 0 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  141.         UI_Done sBuff UIST_String mympegaStrX FETCH UI_GETATTRS
  142.         sBuff ATOF mympegiStrX STORE
  143.         UI_Done sBuff UIST_String mympegaStrY FETCH UI_GETATTRS
  144.         sBuff ATOF mympegiStrY STORE
  145.     ELSE
  146.         UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  147.         UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  148.     ENDIF
  149.     SetPicSize
  150. ;
  151.  
  152. : mympegcbStrX  ( X value for framesize is truncated to a multiple of 16
  153.     ATOF 16 / 16 * mympegiStrX STORE
  154.     UI_Done mympegiStrX FETCH "%d" sBuff SPRINTF sBuff UIST_String mympegaStrX FETCH UI_SETATTRS
  155.     SetPicSize
  156. ;
  157.  
  158. : mympegcbStrY  ( see at X value
  159.     ATOF 16 / 16 * mympegiStrY STORE
  160.     UI_Done mympegiStrY FETCH "%d" sBuff SPRINTF sBuff UIST_String mympegaStrY FETCH UI_SETATTRS
  161.     SetPicSize
  162. ;
  163.  
  164. : CheckPat  ( the given pattern is validated at begining and end
  165.             ( letters in the middle are not checked
  166.     "|n" sBuff SPRINTF
  167.     sBuff mympegsPat 1 NCPY
  168.     sBuff "I" COMPARE IF
  169.         "Has to begin with I " ERROR
  170.         EXIT
  171.     ENDIF
  172.     mympegsPat DUP LEN 1 - + sBuff SWAP 1 NCPY sBuff "B" COMPARE NOT IF
  173.         "Must not end with B " ERROR
  174.         EXIT
  175.     ENDIF
  176. ;
  177.  
  178. : mympegcbMx2  ( get values for pattern from array
  179.                ( only possible by using an external rpl file
  180.    DUP 4 = IF
  181.        DROP
  182.        UI_Done 0 UI_Disabled mympegaPat FETCH UI_SETATTRS
  183.        UI_Done mympegsPat UIST_String mympegaPat FETCH UI_GETATTRS
  184.    ELSE
  185.        UI_Done 1 UI_Disabled mympegaPat FETCH UI_SETATTRS
  186.        ( mympegLab2 SWAP PFETCH mympegsPat CPY
  187.        "r3d3:rpl/MyMPEG-array-Pat.rpl" LOAD
  188.    ENDIF
  189. ;
  190.  
  191. : mympegcbPat
  192.     mympegsPat SPRINTF
  193.     CheckPat
  194. ;
  195.  
  196. : mympegcbStrI
  197.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  198.         "The value must be between 1 and 31 !" ERROR
  199.         DROP
  200.     ELSE
  201.         mympegsStrI SPRINTF
  202.     ENDIF
  203. ;
  204.  
  205. : mympegcbStrB
  206.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  207.         "The value must be between 1 and 31 !" ERROR
  208.         DROP
  209.     ELSE
  210.         mympegsStrB SPRINTF
  211.     ENDIF
  212. ;
  213.  
  214. : mympegcbStrP
  215.     DUP ATOF DUP 1 < SWAP 31 > OR IF
  216.         "The value must be between 1 and 31 !" ERROR
  217.         DROP
  218.     ELSE
  219.         mympegsStrP SPRINTF
  220.     ENDIF
  221. ;
  222.  
  223. : SetPicName  ( writes the picturename into the Rendersettings of the relevant View window
  224.               ( because the RPL-includes for Amiga v3.5 does NOT yet exist numeral values are used
  225.     mympegsStrV WND_ADDR  W.aData + FETCH
  226.     1176 ( VR.sFilename ) + mympegsPFull SWAP CPY
  227. ;
  228.  
  229. : PathParts   ( devide the full name into file and path name
  230.               ( has to be executed after StripPath, due to the right iCount value
  231.     "" mympegsPPath SPRINTF
  232.     mympegsPPath mympegsPFull DUP LEN iCount FETCH - NCAT
  233.     iCount FETCH 1 - iCount STORE
  234.     mympegsPFull DUP LEN iCount FETCH - +
  235.     mympegsPName CPY
  236. ;
  237.  
  238. : StripPath  ( validate picturename and determine iCount for later separation
  239.     mympegsPFull DUP LEN 1 - + "/" COMPARE NOT IF      ( check if it ends with /
  240.         "Name ends with / !" ERROR
  241.         EXIT
  242.     ENDIF
  243.     1 iCount STORE
  244.     "|n" sBuff SPRINTF
  245.     BEGIN  ( LOOP UNTIL first / is reached reverse
  246.         mympegsPFull DUP LEN iCount FETCH - + sBuff SWAP 1 NCPY sBuff "/" COMPARE NOT IF
  247.             EXIT
  248.         ENDIF
  249.         mympegsPFull LEN iCount FETCH < IF  ( end the LOOP IF ...
  250.             "Use at least one subdirectory !" ERROR
  251.             EXIT
  252.         ENDIF
  253.         iCount FETCH 1 + iCount STORE
  254.     AGAIN
  255. ;
  256.  
  257. : COUNTWND
  258.  
  259. 0                   ( INITILIATE COUNTER
  260. "editor" DATABASE   ( GET POINTER TO STRUCTURE
  261. BEGIN               ( START LOOP
  262.     FETCH           ( GET ENTRY
  263.     DUP FETCH       ( GET NEXT ENTRY
  264. WHILE               ( IF STRUCTURE VALID
  265.       SWAP 1 + SWAP ( INCREASE COUNTER
  266. REPEAT              ( RETURN LOOP
  267. DROP                ( DROP ADDRESS OF STRUCTURE
  268. ;
  269.  
  270. : CountView  ( determine the number of View windows
  271.              ( SuperBitMap, Borderless OR DoubleBuffered are not counted
  272.              ( output integer
  273.     0
  274.     "editor" DATABASE
  275.     COUNTWND 0 DO
  276.         FETCH DUP W.iType + FETCH 3 = IF
  277.             SWAP 1 + SWAP
  278.         ENDIF
  279.     LOOP
  280.     DROP
  281. ;
  282.  
  283. : CycleView  ( puts the names of available View windows out
  284.     1 iCount STORE
  285.     "editor" DATABASE
  286.     BEGIN
  287.         FETCH DUP
  288.         W.iType + FETCH 3 = IF
  289.             DUP
  290.             W.aName + FETCH SWAP ( PUTS
  291.         ENDIF
  292.         iCount FETCH COUNTWND > IF DROP EXIT ENDIF
  293.         iCount FETCH 1 + iCount STORE
  294.     AGAIN
  295. ;
  296.  
  297. : mympegcbMx3  ( Cyclegadget for View window selection
  298.                ( here an external rpl file is used also to read from the array
  299.     DUP 0 = IF
  300.         DROP
  301.         UI_Done 1 UI_Disabled mympegaPic FETCH UI_SETATTRS
  302.         UI_Done 1 UI_Disabled mympegaPB FETCH UI_SETATTRS
  303.         UI_Done 1 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  304.         UI_Done 1 UI_Disabled mympegaMB FETCH UI_SETATTRS
  305.         UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  306.     ELSE
  307.         "r3d3:rpl/MyMPEG-array-View.rpl" LOAD
  308.         UI_Done 0 UI_Disabled mympegaPic FETCH UI_SETATTRS
  309.         UI_Done 0 UI_Disabled mympegaPB FETCH UI_SETATTRS
  310.         UI_Done 0 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  311.         UI_Done 0 UI_Disabled mympegaMB FETCH UI_SETATTRS
  312.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  313.  
  314.         mympegsStrV  "attr(W:%s->output)" sBuff SPRINTF  sBuff EVAL iOutput STORE  ( save original outputmode
  315.         mympegsStrV  "attr(W:%s->output)=6" sBuff SPRINTF  sBuff EVAL DROP         ( set output to PPM
  316.         mympegsStrV  "attr(W:%s->filename)" sBuff SPRINTF  sBuff EVAL DUP "" COMPARE  0  =  IF
  317.             DROP sDefPic
  318.         ENDIF
  319.         DUP mympegsPFull CPY
  320.         UI_Done SWAP UIST_String mympegaPic FETCH UI_SETATTRS
  321.         SetPicSize
  322.         SetPicName
  323.         StripPath
  324.         PathParts
  325.         sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  326.         UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  327.     ENDIF
  328.  
  329. ;
  330.  
  331. : mympegcbPic  ( after typing the picturename the MPEG name is changed automatically
  332.     DROP
  333.     UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  334.     SetPicName
  335.     StripPath
  336.     PathParts
  337.     sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  338.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  339. ;
  340.  
  341. : mympegcbGetP  ( filerequester for picturenames
  342.     UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  343.     iIO_SAVE mympegsPFull mympegsPPath "Base picturename" GET_FIL
  344.     IF
  345.         UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_SETATTRS
  346.     ELSE
  347.         UI_Done mympegsPFull UIST_String mympegaPic FETCH UI_GETATTRS
  348.     ENDIF
  349.     SetPicName
  350.     StripPath
  351.     PathParts
  352.     sDefMPEG mympegsPName "%s%smpg" mympegsMFull SPRINTF
  353.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  354. ;
  355.  
  356. : Frames  ( outputs framename without path but with framenumbers - from to - in the right way
  357.     "|n" sBuff SPRINTF
  358.     mympegsPName
  359.     "" "attr(A:->currentfrm)" EVAL "attr(A:->format)" EVAL sBuff1 SPRINTF sBuff1
  360.     "" "attr(A:->frames)" EVAL 1 - "attr(A:->format)" EVAL sBuff2 SPRINTF sBuff2
  361.     "%s*      [%s-%s]" sBuff SPRINTF
  362. ;
  363.  
  364. : mympegcbMPG  ( reads the MPEG name
  365.     DROP
  366.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_GETATTRS
  367. ;
  368.  
  369. : mympegcbGetM  ( filerequester for MPEG name
  370.     "|n" mympegsMFull SPRINTF
  371.     iIO_SAVE mympegsMFull sDefMPEG2 "Name of MPEG" GET_FIL
  372.     IF
  373.         UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  374.     ( ELSE
  375.     (    UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_GETATTRS
  376.     ENDIF
  377. ;
  378.  
  379. : FCGOPs  ( FrameCommand when GOPs are used
  380.     DUP "attr(A:->currentfrm)" EVAL SWAP - 1 + mympegsPat LEN MOD NOT IF
  381.         iGOP FETCH
  382.         mympegsPFull "r3d3:Accessories/mpeg_encodes -gop %d %sparam" sBuff SPRINTF sBuff SYSTEM
  383.         mympegsMFull iGOP FETCH "c:protect %s.gop.%d d sub >nil:" sBuff SPRINTF sBuff SYSTEM
  384.         mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  385.         iGOP FETCH 1 + iGOP STORE
  386.     ELSE
  387.         "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  388.             iGOP FETCH mympegsPFull "r3d3:Accessories/mpeg_encodes -gop %d %sparam" sBuff SPRINTF sBuff SYSTEM
  389.             mympegsMFull iGOP FETCH "c:protect %s.gop.%d d sub >nil:" sBuff SPRINTF sBuff SYSTEM
  390.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  391.         ENDIF
  392.     ENDIF
  393.     "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  394.         DROP     ( the offset for GOPs is droped
  395.         mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_gops %sparam" sBuff SPRINTF sBuff SYSTEM
  396.         mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  397.         mympegsPFull "c:delete %sparam force >nil:" sBuff SPRINTF sBuff SYSTEM
  398.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  399.         UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  400.         sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  401.     ENDIF
  402. ;
  403.  
  404. : FCnoGOPs ( FrameCommand when GOPs are not used
  405.     "attr(A:->currentfrm)" EVAL 1 + "attr(A:->frames)" EVAL = IF
  406.         mympegsPFull "r3d3:Accessories/mpeg_encodes %sparam" sBuff SPRINTF sBuff SYSTEM
  407.         mympegsPFull "c:delete %sparam force >nil:" sBuff SPRINTF sBuff SYSTEM
  408.         UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  409.         UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  410.         sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  411.         "OK|No" "Delete the picture files?" GET_KEY
  412.         IF
  413.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  414.         ENDIF
  415.         QUIT
  416.     ENDIF
  417.  
  418. ;
  419.  
  420. : DumpStrNL ( Input: sString
  421.             ( saves row with CR and LF to file
  422.     mympegaFile FETCH FPUTS 0 < IF
  423.         "Cannot write to a file" ERROR
  424.     ENDIF
  425.     "|n" sBuff SPRINTF
  426.     sBuff mympegaFile FETCH FPUTS 0 < IF
  427.         "Cannot write to a file" ERROR
  428.     ENDIF
  429. ;
  430.  
  431. : mympegcbStart ( start button hit
  432.     UI_Done mympegsMFull UIST_String mympegaMPG FETCH UI_SETATTRS
  433.     DEPTH IF         ( if Pause was hit
  434.         ( do nothing
  435.     ELSE
  436.         "|n" sFrmCmd SPRINTF
  437.         "anim" DATABASE A.sFRAMECMD + sFrmCmd CPY                                  ( save originale framecommand
  438.         mympegsStrV  "attr(W:%s->output)=6" sBuff SPRINTF  sBuff EVAL DROP         ( set outputmode to PPM
  439.         SetPicSize
  440.  
  441.         mympegsPFull "%sparam" sBuff SPRINTF sBuff "w" FOPEN DUP mympegaFile STORE  ( open PARAM file
  442.         NOT IF
  443.             sBuff "Cannot open file %s - START AGAIN" PUTS
  444.             mympegsPFull "protect %sparam d add" sBuff SPRINTF sBuff SYSTEM
  445.             EXIT
  446.         ENDIF
  447.  
  448.         "# This parameter file was created by MyMPEG. " DumpStrNL
  449.         "# A RPL program to create MPEGs from within Real3D v3.5 " DumpStrNL
  450.         "# Written by Marc Bartels " DumpStrNL
  451.         "" DumpStrNL
  452.         "" DumpStrNL
  453.         mympegsPat
  454.         "PATTERN          %s" sBuff SPRINTF sBuff DumpStrNL
  455.         mympegsMFull
  456.         "OUTPUT           %s" sBuff SPRINTF sBuff DumpStrNL
  457.         "" DumpStrNL
  458.         "BASE_FILE_FORMAT PNM" DumpStrNL
  459.         mympegsPat LEN
  460.         "GOP_SIZE         %d" sBuff SPRINTF sBuff DumpStrNL
  461.         mympegiStrY FETCH 16 /
  462.         "SLICES_PER_FRAME %d" sBuff SPRINTF sBuff DumpStrNL
  463.         "" DumpStrNL
  464.         "PIXEL            HALF" DumpStrNL
  465.         "RANGE            10" DumpStrNL
  466.         "PSEARCH_ALG      LOGARITHMIC" DumpStrNL
  467.         "BSEARCH_ALG      CROSS2" DumpStrNL
  468.         mympegsStrI
  469.         "IQSCALE          %s" sBuff SPRINTF sBuff DumpStrNL
  470.         mympegsStrB
  471.         "BQSCALE          %s" sBuff SPRINTF sBuff DumpStrNL
  472.         mympegsStrP
  473.         "PQSCALE          %s" sBuff SPRINTF sBuff DumpStrNL
  474.         "" DumpStrNL
  475.         "REFERENCE_FRAME  ORIGINAL" DumpStrNL
  476.         "FORCE_ENCODE_LAST_FRAME" DumpStrNL                        ( undocumented feature
  477.         mympegiStrX FETCH mympegiStrY FETCH
  478.         "YUV_SIZE         %dx%d" sBuff SPRINTF sBuff DumpStrNL
  479.         mympegsPPath
  480.         "INPUT_DIR        %s" sBuff SPRINTF sBuff DumpStrNL
  481.         "INPUT" DumpStrNL
  482.         Frames                sBuff DumpStrNL
  483.         "END_INPUT" DumpStrNL
  484.         "INPUT_CONVERT    *" DumpStrNL
  485.  
  486.         mympegaFile FETCH FCLOSE                                            ( close file
  487.         IF "Error closing file " ERROR EXIT ENDIF
  488.  
  489.         mympegsPFull "protect %sparam d sub" sBuff SPRINTF sBuff SYSTEM
  490.  
  491.         0 3 6 0 MENUNUM iWC_MENU mympegsStrV iWM_ACTION WND_SENDMSG DROP  ( open Drawing Settings of View window
  492.         
  493.         0 iGOP STORE
  494.         "attr(A:->currentfrm)" EVAL mympegsPat LEN MOD   ( offset for GOPs put on stack
  495.         "attr(A:->currentfrm)" EVAL iStartFrm STORE
  496.  
  497.         UI_Done iCheck UICB_Checked mympegaCheck1 FETCH UI_GETATTRS
  498.         iCheck FETCH IF
  499.             "FCGOPs" "anim" DATABASE A.sFRAMECMD + CPY  ( set framecommand )
  500.         ELSE
  501.             "FCnoGOPs" "anim" DATABASE A.sFRAMECMD + CPY  ( set framecommand )
  502.         ENDIF
  503.     ENDIF
  504.  
  505.     UI_Done 0 UI_Disabled mympegaCB FETCH UI_SETATTRS
  506.     UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  507.  
  508.     4 3 0 MENU        ( used PLAY this way to be able to undo it
  509. ;
  510.  
  511. : mympegcbCancel
  512.     UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  513.     5 4 0 MENU   ( Cancel all
  514.     UI_Done 0 UI_Disabled mympegaSB FETCH UI_SETATTRS
  515.  
  516.     "MPEG|Pause|Delete" "Create MPEG, pause or delete everything?" GET_KEY
  517.         DUP 1 = IF ( MPEG
  518.             iCheck FETCH IF
  519.                 DROP ( the 1 is droped
  520.                 mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM   ( delete pictures only
  521.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_gops %sparam" sBuff SPRINTF sBuff SYSTEM
  522.                 mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  523.                 mympegsPFull "c:delete %sparam force >nil:" sBuff SPRINTF sBuff SYSTEM
  524.                 sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  525.                 DROP ( offset for GOPs is droped
  526.                 QUIT
  527.             ELSE
  528.                 "attr(A:->currentfrm)" EVAL iStartFrm FETCH -
  529.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -frames 0 %d %sparam" sBuff SPRINTF sBuff SYSTEM
  530.                 mympegsPFull "r3d3:Accessories/mpeg_encodes -combine_frames %sparam" sBuff SPRINTF sBuff SYSTEM
  531.                 mympegsPFull "c:delete %sparam force >nil:" sBuff SPRINTF sBuff SYSTEM
  532.                 mympegsMFull "c:delete %s.frame.#? >nil:" sBuff SPRINTF sBuff SYSTEM
  533.                 sDefPlayer mympegsMFull "%s %s" sBuff SPRINTF sBuff SYSTEM
  534.                 "OK|No" "Delete the picture files?" GET_KEY
  535.                 IF
  536.                     mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM
  537.                 ENDIF
  538.                 QUIT
  539.             ENDIF
  540.         ENDIF
  541.         DUP 2 = IF ( Pause
  542.             "You selected Pause, so you may start again later." PUTS
  543.             DROP        ( the 2 is droped, offset for GOPs is left on the stack
  544.             EXIT
  545.         ENDIF
  546.         0 = IF  ( Delete
  547.             mympegsPFull "c:delete %s#? >nil:" sBuff SPRINTF sBuff SYSTEM           ( delete pictures only
  548.             mympegsMFull "c:delete %s.gop.#? force >nil:" sBuff SPRINTF sBuff SYSTEM
  549.             mympegsPFull "c:delete %sparam force >nil:" sBuff SPRINTF sBuff SYSTEM
  550.             QUIT ( also empty stack
  551.         ENDIF
  552. ;
  553.  
  554. : mympegcbHelp
  555.     "r3d3:help/mympeg_gui.guide" "Introduction" 0 AGUIDE
  556. ;
  557.  
  558. : mympegcbClose
  559.     mympegsStrV LEN IF
  560.         mympegsStrV iOutput FETCH "attr(W:%s->output)=%d" sBuff SPRINTF  sBuff EVAL DROP  ( restore original outputmodes
  561.         sFrmCmd "anim" DATABASE A.sFRAMECMD + CPY  ( restore original framecommand
  562.     ENDIF
  563.     mympegaWindow FETCH UI_DELETE   ( delete the window
  564.     NULL mympegaWindow STORE        ( Set mympegaWindow to NULL
  565.     ( REFRESH
  566.     ( FORGET MyMPEG_GUI
  567. ;
  568.  
  569.  
  570. ( Callback for Window. Mouse movements, mouse clicks and close window
  571. ( events are reported.
  572.  
  573. : mympegcbWindow
  574.     PARAM
  575.         VARIABLE iMouseY
  576.         VARIABLE iMouseX
  577.         VARIABLE iEvent
  578.     ENDPARAM
  579.  
  580.     ( Check if iEvent is equal to UIWM_Close
  581.     iEvent FETCH UIWM_Close =
  582.     IF
  583.        ( & ) mympegcbClose ( EXECUTE )
  584.     ENDIF
  585. ;
  586.  
  587. ?ENDIF
  588.  
  589.  
  590. ( Now that we have defined all the required variables and words it is time
  591. ( to create windows and other display elements.
  592.  
  593. ( if window is already open, prompt proper error message and do nothing.
  594. mympegaWindow FETCH
  595.  
  596. ?IF
  597.     "Understood" "Window already opened" GET_KEY DROP
  598. ?ELSE
  599.  
  600.     ( otherwise, open all display elements
  601.  
  602.     ( Open a window
  603.     UI_Done & mympegcbWindow 0 0 326 FONTSIZE 107 + "MyMPEG ©1997 Marc Bartels" UI_WINDOW mympegaWindow STORE
  604.  
  605.     ( create button gadgets, no need to save handles ?
  606.  
  607.     UI_Done mympegaWindow FETCH 0 86 FONTSIZE 5 + 0 12 "Memory  :" UI_TEXT DROP
  608.     UI_Done
  609.     1 UICB_Checked
  610.     mympegaWindow FETCH & mympegcbCheck1 86 FONTSIZE 5 + 50 12 "use GOPs" UI_CHECKBOX mympegaCheck1 STORE
  611.     UI_Done
  612.     0 UICB_Checked
  613.     mympegaWindow FETCH & mympegcbCheck2 86 FONTSIZE 17 + 50 12 "do not use GOPs" UI_CHECKBOX mympegaCheck2 STORE
  614.  
  615.  
  616.     7 PARRAY mympegLab1
  617.     0 "custom" "320 × 256" "352 × 240" "160 × 128" "160 × 112" "128 ×  96" mympegLab1 PINIT
  618.     UI_Done
  619.     1 UIMX_Active
  620.     160 mympegiStrX STORE 112  mympegiStrY STORE
  621.     mympegLab1 UIMX_Labels
  622.     mympegaWindow FETCH & mympegcbMx1 86 FONTSIZE 29 + 108 12 "Size    :" UI_MX mympegaMx1 STORE
  623.  
  624.     UI_Done
  625.     mympegaWindow FETCH & mympegcbStrX 232 FONTSIZE 29 + 44 12 "X Y" UI_STRING mympegaStrX STORE
  626.  
  627.     UI_Done
  628.     mympegaWindow FETCH & mympegcbStrY 276 FONTSIZE 29 + 44 12 "" UI_STRING mympegaStrY STORE
  629.  
  630.  
  631.     6 PARRAY mympegLab2
  632.     0 "custom" "IBBPBBI" "IBP" "IPBP" "IIII" mympegLab2 PINIT
  633.     "IIII" mympegsPat SPRINTF
  634.     UI_Done
  635.     0 UIMX_Active
  636.     mympegLab2 UIMX_Labels
  637.     mympegaWindow FETCH & mympegcbMx2 86 FONTSIZE 41 + 100 12 "Quality :" UI_MX mympegaMx2 STORE
  638.  
  639.     UI_Done
  640.     mympegaWindow FETCH & mympegcbPat 232 FONTSIZE 41 + 88 12 "Pat." UI_STRING mympegaPat STORE
  641.  
  642.     UI_Done "2" DUP mympegsStrI CPY UIST_String
  643.     mympegaWindow FETCH & mympegcbStrI 232 FONTSIZE 53 + 28 12 "IBP" UI_STRING DROP
  644.  
  645.     UI_Done "4" DUP mympegsStrB CPY UIST_String
  646.     mympegaWindow FETCH & mympegcbStrB 262 FONTSIZE 53 + 28 12 "" UI_STRING DROP
  647.  
  648.     UI_Done "6" DUP mympegsStrP CPY UIST_String
  649.     mympegaWindow FETCH & mympegcbStrP 292 FONTSIZE 53 + 28 12 "" UI_STRING DROP
  650.     
  651.  
  652.     CountView 2 + PARRAY mympegLab3
  653.     0 CycleView "(None)" mympegLab3 PINIT
  654.     UI_Done
  655.     0 UIMX_Active
  656.     mympegLab3 UIMX_Labels
  657.     mympegaWindow FETCH & mympegcbMx3 86 FONTSIZE 53 + 100 12 "Window  :" UI_MX mympegaMx3 STORE
  658.  
  659.     UI_Done
  660.     mympegaWindow FETCH & mympegcbPic 86 FONTSIZE 65 + 206 12 "Pictures:" UI_STRING mympegaPic STORE
  661.  
  662.     UI_Done
  663.     mympegaWindow FETCH & mympegcbGetP 292 FONTSIZE 65 + 28 12 "/\\" UI_BUTTON mympegaPB STORE
  664.  
  665.  
  666.     UI_Done
  667.     mympegaWindow FETCH & mympegcbMPG 86 FONTSIZE 77 + 206 12 "MPEGfile:" UI_STRING mympegaMPG STORE
  668.  
  669.     UI_Done
  670.     mympegaWindow FETCH & mympegcbGetM 292 FONTSIZE 77 + 28 12 "/\\" UI_BUTTON mympegaMB STORE
  671.  
  672.  
  673.     UI_Done mympegaWindow FETCH & mympegcbStart   6 FONTSIZE 91 + 75 12 "Start"  UI_BUTTON mympegaSB STORE
  674.     UI_Done mympegaWindow FETCH & mympegcbCancel 85 FONTSIZE 91 + 75 12 "Cancel" UI_BUTTON mympegaCB STORE
  675.     UI_Done mympegaWindow FETCH & mympegcbHelp  166 FONTSIZE 91 + 75 12 "Help"   UI_BUTTON DROP
  676.     UI_Done mympegaWindow FETCH & mympegcbClose 245 FONTSIZE 91 + 75 12 "Close"  UI_BUTTON DROP
  677.  
  678.     
  679.     mympegaWindow FETCH UI_REALIZE         ( realize display elements
  680.  
  681. ?ENDIF
  682. UI_Done 1 UI_Disabled mympegaStrX FETCH UI_SETATTRS
  683. UI_Done 1 UI_Disabled mympegaStrY FETCH UI_SETATTRS
  684. UI_Done 1 UI_Disabled mympegaPat FETCH UI_SETATTRS
  685. UI_Done 1 UI_Disabled mympegaPic FETCH UI_SETATTRS
  686. UI_Done 1 UI_Disabled mympegaPB FETCH UI_SETATTRS
  687. UI_Done 1 UI_Disabled mympegaMPG FETCH UI_SETATTRS
  688. UI_Done 1 UI_Disabled mympegaMB FETCH UI_SETATTRS
  689. UI_Done 1 UI_Disabled mympegaSB FETCH UI_SETATTRS
  690. UI_Done 1 UI_Disabled mympegaCB FETCH UI_SETATTRS
  691.  
  692.  
  693. ( FORGET MyMPEG_GUI
  694.